/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import interfaces.CompanyAdquiredProfileCapable;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "company_adquired_profile")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CompanyAdquiredProfile.findAll", query = "SELECT c FROM CompanyAdquiredProfile c"),
    @NamedQuery(name = "CompanyAdquiredProfile.findByIdCompanyAdquiredProfile", query = "SELECT c FROM CompanyAdquiredProfile c WHERE c.idCompanyAdquiredProfile = :idCompanyAdquiredProfile"),
    @NamedQuery(name = "CompanyAdquiredProfile.findByPrice", query = "SELECT c FROM CompanyAdquiredProfile c WHERE c.price = :price"),
    @NamedQuery(name = "CompanyAdquiredProfile.findByIsPayed", query = "SELECT c FROM CompanyAdquiredProfile c WHERE c.isPayed = :isPayed"),
    @NamedQuery(name = "CompanyAdquiredProfile.findByAdquisitionDate", query = "SELECT c FROM CompanyAdquiredProfile c WHERE c.adquisitionDate = :adquisitionDate"),
    @NamedQuery(name = "CompanyAdquiredProfile.findByCandidateAndCompany", query = "SELECT c FROM CompanyAdquiredProfile c WHERE c.candidate.idCandidate = :idCandidate AND c.company.idCompany = :idCompany"),
    @NamedQuery(name = "CompanyAdquiredProfile.findByPayDate", query = "SELECT c FROM CompanyAdquiredProfile c WHERE c.payDate = :payDate")})
public class CompanyAdquiredProfile implements Comparable<CompanyAdquiredProfile>,Serializable,CompanyAdquiredProfileCapable {
    @JoinColumn(name = "FOLDER", referencedColumnName = "ID_COMPANY_FOLDER")
    @ManyToOne
    private CompanyFolder folder;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "companyAdquiredProfile")
    private List<CompanyAdquiredProfileFolder> companyAdquiredProfileFolderList;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_COMPANY_ADQUIRED_PROFILE")
    private Integer idCompanyAdquiredProfile;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PRICE")
    private BigDecimal price;
    @Basic(optional = false)
    @NotNull
    @Column(name = "IS_PAYED")
    private boolean isPayed;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ADQUISITION_DATE")
    @Temporal(TemporalType.DATE)
    private Date adquisitionDate;
    @Column(name = "PAY_DATE")
    @Temporal(TemporalType.DATE)
    private Date payDate;
    @JoinColumn(name = "CANDIDATE", referencedColumnName = "ID_CANDIDATE")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Candidate candidate;
    @JoinColumn(name = "COMPANY", referencedColumnName = "ID_COMPANY")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Company company;

    public CompanyAdquiredProfile() {
    }

    public CompanyAdquiredProfile(Integer idCompanyAdquiredProfile) {
        this.idCompanyAdquiredProfile = idCompanyAdquiredProfile;
    }

    public CompanyAdquiredProfile(Integer idCompanyAdquiredProfile, boolean isPayed, Date adquisitionDate) {
        this.idCompanyAdquiredProfile = idCompanyAdquiredProfile;
        this.isPayed = isPayed;
        this.adquisitionDate = adquisitionDate;
    }

    public Integer getIdCompanyAdquiredProfile() {
        return idCompanyAdquiredProfile;
    }

    public void setIdCompanyAdquiredProfile(Integer idCompanyAdquiredProfile) {
        this.idCompanyAdquiredProfile = idCompanyAdquiredProfile;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public boolean getIsPayed() {
        return isPayed;
    }

    public void setIsPayed(boolean isPayed) {
        this.isPayed = isPayed;
    }

    public Date getAdquisitionDate() {
        return adquisitionDate;
    }

    public void setAdquisitionDate(Date adquisitionDate) {
        this.adquisitionDate = adquisitionDate;
    }

    public Date getPayDate() {
        return payDate;
    }

    public void setPayDate(Date payDate) {
        this.payDate = payDate;
    }

    @Override
    public Candidate getCandidate() {
        return candidate;
    }

    public void setCandidate(Candidate candidate) {
        this.candidate = candidate;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCompanyAdquiredProfile != null ? idCompanyAdquiredProfile.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompanyAdquiredProfile)) {
            return false;
        }
        CompanyAdquiredProfile other = (CompanyAdquiredProfile) object;
        if ((this.idCompanyAdquiredProfile == null && other.idCompanyAdquiredProfile != null) || (this.idCompanyAdquiredProfile != null && !this.idCompanyAdquiredProfile.equals(other.idCompanyAdquiredProfile))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CompanyAdquiredProfile[ idCompanyAdquiredProfile=" + idCompanyAdquiredProfile + " ]";
    }

    @XmlTransient
    public List<CompanyAdquiredProfileFolder> getCompanyAdquiredProfileFolderList() {
        return companyAdquiredProfileFolderList;
    }

    public void setCompanyAdquiredProfileFolderList(List<CompanyAdquiredProfileFolder> companyAdquiredProfileFolderList) {
        this.companyAdquiredProfileFolderList = companyAdquiredProfileFolderList;
    }

    public CompanyFolder getFolder() {
        return folder;
    }

    public void setFolder(CompanyFolder folder) {
        this.folder = folder;
    }

    @Override
    public CompanyAdquiredProfile getCompanyAdquiredProfile() {
        return this;
    }

    @Override
    public int compareTo(CompanyAdquiredProfile cap) {
        return this.getAdquisitionDate().compareTo(cap.getAdquisitionDate());
    }
    
}
